#!/bin/sh
. $HOME/.config/defaultprograms.txt
case "$1" in
 -default)
 echo $MUSICPLAYER > $HOME/.config/tmp/player
 
 programchooser $MUSICPLAYER multimedia-player "Player" None > $HOME/.config/tmp/musicplayer
 cat $HOME/.config/defaultprograms.txt | grep -v MUSICPLAYER > $HOME/.config/defaultprograms.new
 MUSICPLAYER="`cat $HOME/.config/tmp/musicplayer`"
 [ "$MUSICPLAYER" = "" ] && MUSICPLAYER="cat $HOME/.config/tmp/player"
 echo MUSICPLAYER=\"$MUSICPLAYER\" >> $HOME/.config/defaultprograms.new
 mv -f $HOME/.config/defaultprograms.new $HOME/.config/defaultprograms.txt
 rm -f $HOME/.config/tmp/player
 rm -f $HOME/.config/tmp/musicplayer
 ;;
 *)
 exec $MUSICPLAYER "$@"
 ;;
esac
